package com.broadengate.view.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.broadengate.bean.BillInfo;
import com.broadengate.service.BillService;
import com.broadengate.view.model.BillModel;
import com.broadengate.view.pageModel.DataGrid;

@Controller
@RequestMapping("/BillController")
public class BillController {

	@Autowired
	private BillService billService;

	@RequestMapping("/dataGrid")
	@ResponseBody
	public DataGrid getBillList(BillModel model) throws Exception {
		List<BillInfo> billInfoList = billService.queryByList(model);
		DataGrid datagrid = new DataGrid();
		datagrid.setRows(billInfoList);
		datagrid.setTotal(billService.queryByCount(model));
		return datagrid;
	}

	@RequestMapping("/getBillListByPo")
	@ResponseBody
	public DataGrid getBillListByPo(BillModel model) throws Exception {
		List<BillInfo> billInfoList = billService.queryBillListByPo(model);
		DataGrid datagrid = new DataGrid();
		if (billInfoList != null && billInfoList.size() > 0) {
			datagrid.setTotal(billInfoList.size());
		}
		datagrid.setRows(billInfoList);

		return datagrid;
	}
}
